package com.hq.ims.data.vo;

import com.hq.authority.utils.AppUtils;
import com.hq.ims.data.config.verification.VdAdd;
import com.hq.ims.data.config.verification.VdEdit;
import com.hq.ims.data.entity.BusiChange;
import com.hq.ims.data.entityenum.EnumChangeWay;
import com.hq.ims.data.vo.auth.BaseRowAuthVo;
import com.hq.utils.util.ListUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @author 蒋柏平
 * @since 20241204
 */
@Mapper
public interface BusiChangeMapstruct {

    BusiChangeMapstruct INSTANCE = Mappers.getMapper(BusiChangeMapstruct.class);

    //-------------------------------- 转换VO类 --------------------------------

    @Mappings({
    })
    BusiChangeVo toBusiChangeVo(BusiChange source);

    default List<BusiChangeVo> toBusiChangeVoList(List<BusiChange> source){
        if (source == null) {
            return ListUtils.newEmptyList();
        }
        return source.stream().map(this::toBusiChangeVo).collect(Collectors.toList());
    }

    //-------------------------------- 以下为自定义类[输出对象] --------------------------------

    @ApiModel(value = "原始对象的扩展类")
    @Data
    class BusiChangeVo extends BusiChange {
        
    }

    @ApiModel(value = "行级权限对象")
    @Data
    class BusiChangeRowAuthVo extends BaseRowAuthVo {

        //自定义其它行级权限


        //构造函数
        public BusiChangeRowAuthVo(BusiChange entity){
            //当前操作用户ID
            String userId = AppUtils.getUserId();
        }
        
    }


    //-------------------------------- 以下为自定义类[输入对象] --------------------------------

    @ApiModel(value = "搜索VO")
    @Data
    class PageSearchVo {

        @ApiModelProperty(value = "经营信息id")
        private String busiInfoId;
    }

    @ApiModel(value = "添加和修改对象")
    @Data
    class SaveVo {

        @NotBlank(message = "数据ID不能为空", groups = {VdEdit.class})
        @ApiModelProperty(value = "数据ID")
        private String busiChangeId;

        @NotBlank(message = "经营信息id不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 32, message = "经营信息id长度不能超过32", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "经营信息id")
        private String busiInfoId;

        @NotBlank(message = "变更内容不能为空", groups = {VdAdd.class, VdEdit.class})
        @Size(min = 1, max = 255, message = "变更内容长度不能超过255", groups = {VdAdd.class, VdEdit.class})
        @ApiModelProperty(value = "变更内容")
        private String changeContent;

        @ApiModelProperty(value = "变更前内容")
        private String changeBefore;

        @ApiModelProperty(value = "变更后内容")
        private String changeAfter;

        @ApiModelProperty(value = "变更方式")
        private EnumChangeWay changeWay;

        @ApiModelProperty(value = "变更时间")
        private LocalDateTime changeTime;



    }

    //-------------------------------- springboot验证标识 --------------------------------

}
